home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vbmask / maskdemo.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  4.7 KB  |  145 lines

  1. VERSION 2.00
  2. Begin Form MaskDemo 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Mask Demo"
  5.    ClientHeight    =   6960
  6.    ClientLeft      =   1170
  7.    ClientTop       =   1470
  8.    ClientWidth     =   6165
  9.    FontBold        =   -1  'True
  10.    FontItalic      =   0   'False
  11.    FontName        =   "MS Sans Serif"
  12.    FontSize        =   24
  13.    FontStrikethru  =   0   'False
  14.    FontUnderline   =   0   'False
  15.    Height          =   7365
  16.    Icon            =   0
  17.    Left            =   1110
  18.    LinkMode        =   1  'Source
  19.    LinkTopic       =   "Form1"
  20.    MaxButton       =   0   'False
  21.    ScaleHeight     =   464
  22.    ScaleMode       =   3  'Pixel
  23.    ScaleWidth      =   411
  24.    Top             =   1125
  25.    Width           =   6285
  26.    Begin CommandButton Command2 
  27.       Caption         =   "Clear"
  28.       FontBold        =   -1  'True
  29.       FontItalic      =   0   'False
  30.       FontName        =   "MS Sans Serif"
  31.       FontSize        =   9.75
  32.       FontStrikethru  =   0   'False
  33.       FontUnderline   =   0   'False
  34.       Height          =   435
  35.       Left            =   3990
  36.       TabIndex        =   5
  37.       Top             =   3450
  38.       Width           =   2175
  39.    End
  40.    Begin CommandButton Command1 
  41.       Caption         =   "(Destination AND Mask) XOR Image"
  42.       FontBold        =   -1  'True
  43.       FontItalic      =   0   'False
  44.       FontName        =   "MS Sans Serif"
  45.       FontSize        =   9.75
  46.       FontStrikethru  =   0   'False
  47.       FontUnderline   =   0   'False
  48.       Height          =   435
  49.       Left            =   0
  50.       TabIndex        =   4
  51.       Top             =   3450
  52.       Width           =   3990
  53.    End
  54.    Begin PictureBox Pic_Mask 
  55.       AutoSize        =   -1  'True
  56.       BorderStyle     =   0  'None
  57.       Height          =   3075
  58.       Left            =   3090
  59.       Picture         =   MASKDEMO.FRX:0000
  60.       ScaleHeight     =   205
  61.       ScaleMode       =   3  'Pixel
  62.       ScaleWidth      =   205
  63.       TabIndex        =   1
  64.       Top             =   0
  65.       Width           =   3075
  66.    End
  67.    Begin PictureBox Pic_Image 
  68.       AutoSize        =   -1  'True
  69.       BorderStyle     =   0  'None
  70.       Height          =   3075
  71.       Left            =   0
  72.       Picture         =   MASKDEMO.FRX:53C2
  73.       ScaleHeight     =   205
  74.       ScaleMode       =   3  'Pixel
  75.       ScaleWidth      =   205
  76.       TabIndex        =   0
  77.       Top             =   0
  78.       Width           =   3075
  79.    End
  80.    Begin Label Label2 
  81.       Alignment       =   2  'Center
  82.       Caption         =   "Mask"
  83.       FontBold        =   -1  'True
  84.       FontItalic      =   0   'False
  85.       FontName        =   "MS Sans Serif"
  86.       FontSize        =   13.5
  87.       FontStrikethru  =   0   'False
  88.       FontUnderline   =   0   'False
  89.       Height          =   375
  90.       Left            =   3090
  91.       TabIndex        =   3
  92.       Top             =   3060
  93.       Width           =   3075
  94.    End
  95.    Begin Label Label1 
  96.       Alignment       =   2  'Center
  97.       Caption         =   "Image"
  98.       FontBold        =   -1  'True
  99.       FontItalic      =   0   'False
  100.       FontName        =   "MS Sans Serif"
  101.       FontSize        =   13.5
  102.       FontStrikethru  =   0   'False
  103.       FontUnderline   =   0   'False
  104.       Height          =   375
  105.       Left            =   0
  106.       TabIndex        =   2
  107.       Top             =   3060
  108.       Width           =   3060
  109.    End
  110. DefInt A-Z
  111. Declare Function BitBlt Lib "Gdi" (ByVal destHdc, ByVal X, ByVal Y, ByVal w, ByVal h, ByVal srcHdc, ByVal srcX, ByVal srcY, ByVal Rop As Long)
  112. Const SRCAND = &H8800C6
  113. Const SRCINVERT = &H660046
  114. Sub Command1_Click ()
  115.     Refresh
  116.     ' ** Display Bitmap with center of it being transparent
  117.     ' Logic is:  (Dest AND Mask) XOR Image
  118.     '
  119.     YDest = Command1.Top + Command1.Height
  120.     R = BitBlt(Hdc, 0, YDest, Pic_Mask.Width, Pic_Mask.Height, Pic_Mask.Hdc, 0, 0, SRCAND)
  121.     R = BitBlt(Hdc, 0, YDest, Pic_Image.Width, Pic_Image.Height, Pic_Image.Hdc, 0, 0, SRCINVERT)
  122.     XDest = Pic_Image.Width + 1
  123.     R = BitBlt(Hdc, XDest, YDest, Pic_Mask.Width, Pic_Mask.Height, Pic_Mask.Hdc, 0, 0, SRCAND)
  124.     R = BitBlt(Hdc, XDest, YDest, Pic_Image.Width, Pic_Image.Height, Pic_Image.Hdc, 0, 0, SRCINVERT)
  125. End Sub
  126. Sub Command2_Click ()
  127.     Refresh
  128. End Sub
  129. Sub Form_Load ()
  130.     Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
  131. End Sub
  132. Sub Form_Paint ()
  133.     ' ** Display something random text on the form **
  134.     '
  135.     Cls
  136.     CurrentY = Command1.Top + Command1.Height
  137.     Rows = (ScaleHeight - CurrentY) \ TextHeight(" ")
  138.     For Y = 1 To Rows
  139.         Print "DESTINATION DESTINATION"
  140.     Next Y
  141. End Sub
  142. Sub Form_Resize ()
  143.     Refresh
  144. End Sub
  145.